// MK2 ControlModule
import subumbo.audio.generator.Turntable;

private var _timer:Timer = new Timer(50);

private var _toneArmDragging:Boolean;
private var _scratching:Boolean;

private var _scratchDelta:Number = 0;


private const TONE_ARM_CLOCK_WISE_CONSTRAINT:Number = 60;
private const TONE_ARM_ANTI_CLOCK_WISE_CONSTRAINT:Number = -10;
/**
 *Properties 
 */
private var _speed:Number = 4;
private var _sensitivity:Number = 30;
private var _playing:Boolean;
public var _controller:Turntable;
			
private function init():void
{
	plate.addChild(slipmat);
	plate.addChild(vinyl);
	_controller = Turntable(AudioEngine.instance.getGenerator("banda"));
	_timer.addEventListener(TimerEvent.TIMER, update);
}

public function startStop():void
{
	if(!_playing)
	{
		_controller.activate();
		_timer.start();	
	}else
	{
		_controller.deactivate();
		_timer.stop();
	}
	_playing = !_playing;
}

private function update(e:TimerEvent):void
{
	
	if(_toneArmDragging) updateToneArm();
	
	if(_scratching)updatePlate();
	plate.rotation += _speed;
}
